ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
UTILS.c File Reference

Side-project utilities that help with data manipulation. More...

#include "derivative.h"
#include "utils.h"
#include <limits.h>

Functions

uint8_t u8fnCheckOddParity (uint8_t u8Byte, uint8_t u8ParityPosition)
 Checks a byte for odd parity.
uint16_t u16fnCheckOddParity (uint16_t u16Word, uint16_t u16ParityPosition)
 Checks a 16-bit word for odd parity.
uint32_t u32fnCheckOddParity (uint32_t u32Word, uint32_t u32ParityPosition)
 Checks a 32-bit word for odd parity.
uint8_t u8fnCRC8 (const uint8_t *pu8Buffer, uint8_t u8Poly, uint8_t u8MBitsize, uint8_t u8Remainder)
 Compute a 8-bit CRC using a custom polynomial.
void vfnASCIIByteToHex (uint8_t *pu8Source, uint8_t *pu8Target, uint16_t u16NOfBytes)
 Converts a data stream from ASCII words to HEX values. Note that Hex-values represented by two ASCII symbols are converted as two separate HEX values.
void vfnHexToASCIIMaskToList (const uint16_t cu16MaskList, uint8_t *pau8DataArray, uint16_t *pu16Index, const uint16_t cu16Mask)
 Takes a mask list, and a particular mask value, and writes its position in ASCII in a given array, at the passed index position, followed by a comma and an empty space.
void vfnHexToASCII (uint8_t *pu8Source, uint8_t *pu8Target, uint16_t u16NOfBytes)
 Converts a data stream from Hex to ASCII values.
void vfnCopyArray (uint8_t *pu8Source, uint8_t *pu8Target, uint16_t u16NOfBytes)
 Copies an array to a different location using only code (no DMA).
uint16_t u16fnMaxU16DeltaInArray (const uint16_t *au16Array, uint8_t u8ArraySize)
 Finds the max and the min values in a 16-bit array, and returns the difference between them.
uint32_t u32fnDiffAbsoluteValue (uint32_t au32Value1, uint32_t au32Value2)
 Performs the absolute value of the difference between two numbers.

Variables

const uint8_t cau8OddParityTable []

Detailed Description

Side-project utilities that help with data manipulation.

Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
R11515
R54967
Version:
Date:
Warning:
(If needed)

History:


Function Documentation

uint16_t u16fnCheckOddParity ( uint16_t  u16Word,
uint16_t  u16ParityPosition 
)

Checks a 16-bit word for odd parity.

Parameters:
u16Word,:Word to be checked for parity.
u16ParityPosition,:If non-zero, adds the parity bit to the byte if needed.
Returns:
If u16ParityPosition is clear, it will return a zero if the word is already odd parity, or a one if it isn't. If u16Parity contains a bit set, it will return u16Word with a parity bit set or cleared, as needed, on the position placed on u16ParityPosition.
uint16_t u16fnMaxU16DeltaInArray ( const uint16_t *  au16Array,
uint8_t  u8ArraySize 
)

Finds the max and the min values in a 16-bit array, and returns the difference between them.

Parameters:
au16Array,:pointer to the array to be analized.
u8ArraySize,:Number of elements in the array.
Returns:
Max - Min.
uint32_t u32fnCheckOddParity ( uint32_t  u32Word,
uint32_t  u32ParityPosition 
)

Checks a 32-bit word for odd parity.

Parameters:
u32Word,:Word to be checked for parity.
u32ParityPosition,:If non-zero, adds the parity bit to the byte if needed.
Returns:
If u32ParityPosition is clear, it will return a zero if the word is already odd parity, or a one if it isn't. If u32Parity contains a bit set, it will return u32Word with a parity bit set or cleared, as needed, on the position placed on u32ParityPosition.
uint32_t u32fnDiffAbsoluteValue ( uint32_t  au32Value1,
uint32_t  au32Value2 
)

Performs the absolute value of the difference between two numbers.

Parameters:
au32Value1,:First number
au32Value2,:Second number
Returns:
Absolute value of (au32Value1 - au32Value2)
uint8_t u8fnCheckOddParity ( uint8_t  u8Byte,
uint8_t  u8ParityPosition 
)

Checks a byte for odd parity.

Parameters:
u8Byte,:Byte to be checked for parity.
u8ParityPosition,:If non-zero, adds the parity bit to the byte if needed.
Returns:
If u8ParityPosition is clear, it will return a zero if the byte is already odd parity, or a one if it isn't. If u8Parity contains a bit set, it will return u8Byte with a parity bit set or cleared, as needed, on the position placed on u8ParityPosition.
uint8_t u8fnCRC8 ( const uint8_t *  pu8Buffer,
uint8_t  u8Poly,
uint8_t  u8MBitsize,
uint8_t  u8Remainder 
)

Compute a 8-bit CRC using a custom polynomial.

Parameters:
pu8Buffer,:Pointer to initial 8-bit element to check.
u8Poly,:Polynomial associated to the division.
u8MBitsize,:Number of bits to check.
Returns:
u8Remainder: Checksum.
void vfnASCIIByteToHex ( uint8_t *  pu8Source,
uint8_t *  pu8Target,
uint16_t  u16NOfBytes 
)

Converts a data stream from ASCII words to HEX values. Note that Hex-values represented by two ASCII symbols are converted as two separate HEX values.

Parameters:
pu8Source,:Pointer to initial element to convert
pu8Target,:Pointer to initial element in the target
u16NOfBytes,:Size in bytes of stream to convert
Returns:
void.
void vfnCopyArray ( uint8_t *  pu8Source,
uint8_t *  pu8Target,
uint16_t  u16NOfBytes 
)

Copies an array to a different location using only code (no DMA).

Parameters:
pu8Source,:Pointer to initial element to copy
pu8Target,:Pointer to initial element to where to copy
u16NOfBytes,:Size in bytes of stream to copy
Returns:
void
void vfnHexToASCII ( uint8_t *  pu8Source,
uint8_t *  pu8Target,
uint16_t  u16NOfBytes 
)

Converts a data stream from Hex to ASCII values.

Parameters:
pu8Source,:Pointer to initial element to convert
pu8Target,:Pointer to initial element in the target
u16NOfBytes,:Size in bytes of stream to convert
Returns:
void.
void vfnHexToASCIIMaskToList ( const uint16_t  cu16MaskList,
uint8_t *  pau8DataArray,
uint16_t *  pu16Index,
const uint16_t  cu16Mask 
)

Takes a mask list, and a particular mask value, and writes its position in ASCII in a given array, at the passed index position, followed by a comma and an empty space.

Parameters:
cu16MaskList,:Mask list containing element to evaluate.
pau8DataArray,:Array were the result will be written.
pu16Index,:Location where the ASCII value will be written. It will be updated to the next free location after the call.
cu16Mask,:Mask value to compare the cu16MaskList against.
Returns:
void

Variable Documentation

const uint8_t cau8OddParityTable[]
Initial value:
 
{
  
  
  
     0u, 1u, 1u, 0u, 1u, 0u, 0u, 1u, 1u, 0u, 0u, 1u, 0u, 1u, 1u, 0u
    
}